package com.gxuwz.medical.domain.role;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.gxuwz.medical.dao.RoleDao;
import com.gxuwz.medical.database.DbUtil;
import com.gxuwz.medical.domain.menu.*;
import com.gxuwz.medical.vo.PageBean;
/**
 * 角色实体类
 * @author 演示
 *
 */
public class Role {
	/**
	 * 角色编号
	 */
	private String roleid;
	/**
	 * 角色名称
	 */
	private String roleName;
    /**
     * 角色对应权限列表
     */
	private Set<Menu> menus = new HashSet();
	
	private RoleDao roledao = new RoleDao();
	
	public void addMenu(String menuid){
		Menu m = new Menu();
		m.setMenuid(menuid);
		menus.add(m);
	}
	
	public void add() throws SQLException {
		roledao.add(this);
	}

	public void delete(String roleid) throws SQLException {
		roledao.delete(roleid);
	}

	public Role query() throws SQLException {
		return roledao.query(roleid);
	}

	public PageBean queryAll(int page,int size) throws SQLException {	
			return roledao.queryAll(page,size);
	}
	public List<Role> queryAll() throws SQLException {	
		return roledao.queryAll();
	}

	public void update() throws SQLException {
		roledao.update(this);
	}
	
	public String getRoleid() {
		return roleid;
	}
	public void setRoleid(String roleid) {
		this.roleid = roleid;
	}
	public String getRoleName() {
		return roleName;
	}
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
	public Set<Menu> getMenus() {
		return menus;
	}
	public void setMenus(Set<Menu> menus) {
		this.menus = menus;
	}

}
